package com.idbk.chargestation.bean;

import android.os.Parcel;
import android.os.Parcelable;

import com.google.gson.annotations.SerializedName;

/**
 * 充电点一览详细信息
 * 注意，这里实现 parcelable接口，方便传递数据。当前没有将所有字段都传递过去，只传递目前有用到的
 * @author liangzw,lupc
 *
 */
public class JsonPointsOverview implements Parcelable {
	
	/**
	 * 在bundle传值的时候 用作 key
	 */
	public final static String KEY = JsonPointsOverview.class.getSimpleName();
	
	@SerializedName("id")
	public int id;//充电点Id
	
	@SerializedName("name")
	public String name;//充电点名称

	@SerializedName("lat")
	public double lat;//纬度

	@SerializedName("lng")
	public double lng;//经度

	@SerializedName("address")
	public String address;//地址

	@SerializedName("isCollection")
	public boolean isCollection;//当前用户是否收藏

	@SerializedName("count4Favorite")
	public int count4Favorite;//收藏数

	@SerializedName("count4Comment")
	public int count4Comment;//评论数

	@SerializedName("isPraise")
	public boolean isPraise;//是否点赞

	@SerializedName("count4Praise")
	public int count4Praise;//点赞数

	@SerializedName("count4Pile")
	public int count4Pile;//电桩数量

	@SerializedName("idleNum")
	public int idleNum;//空闲的桩数

	@SerializedName("available")
	public int available;//是否可用

	@SerializedName("isFree")
	public boolean isFree;//是否免费

	@SerializedName("isOpening")
	public boolean isOpening;//是否对外开放

	@SerializedName("bookSupport")
	public boolean bookSupport;//是否支持预约

	@SerializedName("pointType")
	public String pointType;//充电点包含桩的类型和个数

	@SerializedName("operatorId")
	public int operatorId;//运营商Id

	@SerializedName("slowCharge")
	public boolean isSlow;//是否慢充
	
	@SerializedName("fastCharge")
	public boolean isFast;//是否快充
	
	@SerializedName("superCharge")
	public boolean isSuper;//是否超充
	
	@SerializedName("flag4Confirm")
	public int flag4Confirm;//是否官方，0：官方，1：第三方未认证，2：第三方已认证	

	@SerializedName("isOnline")
	public boolean isOnline;//是否在线

	@SerializedName("mark")
	public String mark;
	
	/**
	 * 距离
	 * 注意：该值为手机端计算所得，且该值在使用之前必须重新计算一次
	 */
	public float distance;
	
	@Override
	public int describeContents() {
		
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeInt(id);
		dest.writeString(name);
		dest.writeDouble(lat);
		dest.writeDouble(lng);		
		dest.writeString(address);
		dest.writeBooleanArray(new boolean[]{isCollection});
		dest.writeInt(count4Pile);
		dest.writeInt(idleNum);
		dest.writeBooleanArray(new boolean[]{isOpening,isOnline,isFree});
		dest.writeInt(count4Comment);
		dest.writeInt(operatorId);
	}
	
	public final static Parcelable.Creator<JsonPointsOverview> CREATOR = new Creator<JsonPointsOverview>() {
		
		@Override
		public JsonPointsOverview[] newArray(int size) {
			// TODO Auto-generated method stub
			return new JsonPointsOverview[size];
		}
		
		@Override
		public JsonPointsOverview createFromParcel(Parcel source) {
			// TODO Auto-generated method stub
			return new JsonPointsOverview(source);
		}
	};
	
	/**
	 * 默认构造方法
	 */
	public JsonPointsOverview(){
		
	}
	
	/**
	 * 反序列化构造方法
	 * @param in
	 */
	public JsonPointsOverview(Parcel in){
		id = in.readInt();
		name = in.readString();
		lat = in.readDouble();
		lng = in.readDouble();
		address = in.readString();
		boolean[] ic = new boolean[1];
		in.readBooleanArray(ic);
		isCollection = ic[0];
		count4Pile = in.readInt();
		idleNum = in.readInt();
		boolean[] b = new boolean[3];
		in.readBooleanArray(b);
		isOpening = b[0];
		isOnline = b[1];
		isFree = b[2];
		count4Comment = in.readInt();
		operatorId = in.readInt();
	}

};
